package cn.itsource.system.controller;

import cn.itsource.system.domain.Logininfo;

import cn.itsource.system.service.ILogininfoService;
import cn.itsource.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LogininfoController {

    @Autowired
    private ILogininfoService logininfoService;

    @PostMapping
    public AjaxResult login(@RequestBody Logininfo logininfo){

        try {
            return AjaxResult.me().setResultObj(logininfoService.login(logininfo));
        } catch (RuntimeException e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("网络繁忙,卿稍后再试");
        }

    }
}
